package com.syni.mdd.sjb.common.datatreaure.config.pay.alipay;

import com.syni.mdd.sjb.common.component.utils.common.spring.ApplicationContextHolder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

@Configuration
@DependsOn("applicationContextHolder")
public class PayConfigRun {

    //测试环境
    private final static String ALI_CALL_BACK_URL_DEV = "http://dg.syni.com/MDD_API/dxshapp/aliPay/AppAliPayNotify";
    private final static String WX_CALL_BACK_URL_DEV = "http://dg.syni.com/MDD_API/dxshapp/wechatPay/AppWechatPayNotify";


    //预生产环境
    private final static String ALI_CALL_BACK_URL_PREO = "https://mpsaas.syni.com/MDD_API/dxshapp/aliPay/AppAliPayNotify";
    private final static String WX_CALL_BACK_URL_PREO = "https://mpsaas.syni.com/MDD_API/dxshapp/wechatPay/AppWechatPayNotify";

    //正式环境
    private final static String ALI_CALL_BACK_URL_PRO = "https://midongdong.com/MDD_API/dxshapp/aliPay/AppAliPayNotify";
    private final static String WX_CALL_BACK_URL_PRO = "https://midongdong.com/MDD_API/dxshapp/wechatPay/AppWechatPayNotify";


    @Bean("payConfig")
    public PayConfig payNotifyUrl(){
        PayConfig payConfig = new PayConfig();
        payConfig.setAlicallBackUrl(ALI_CALL_BACK_URL_DEV);
        payConfig.setWxcallBackUrl(WX_CALL_BACK_URL_DEV);
        if(ApplicationContextHolder.checkRunProfile(ApplicationContextHolder.RUN_PRO)){
            payConfig.setAlicallBackUrl(ALI_CALL_BACK_URL_PRO);
            payConfig.setWxcallBackUrl(WX_CALL_BACK_URL_PRO);
        }else if(ApplicationContextHolder.checkRunProfile(ApplicationContextHolder.RUN_PREO)){
            payConfig.setAlicallBackUrl(ALI_CALL_BACK_URL_PREO);
            payConfig.setWxcallBackUrl(WX_CALL_BACK_URL_PREO);
        }
        return payConfig;
    }
}
